<%@ page language="java" import="java.util.*,java.sql.*,telbook.JDBCUtils" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查看好友</title>
<style type="text/css">
	/*表格样式*/			
	table {
		width: 90%;
		background: #ccc;
		margin: 10px auto;
		border-collapse: collapse;/*border-collapse:collapse合并内外边距(去除表格单元格默认的2个像素内外边距*/	
	}				
	th,td {
		height: 25px;
		line-height: 25px;
		text-align: center;
		border: 1px solid #ccc;
	}		
	th {
		background: #eee;
		font-weight: normal;
	}		
	tr {
		background: #fff;
	}		
	tr:hover {
		background: #cc0;
	}		
	td a {
		color: #06f;
		text-decoration: none;
		 margin-left: 15%;
	}		
	td a:hover {
		color: #06f;
		text-decoration: underline;
	}
	td input{
            border: none;
            font-size: 16px;
            
            background-color:transparent;
            color: #06f;
        }
        td input:hover{
            cursor: pointer;
            text-decoration: underline;
        }
</style>
</head>

<body>
<%
	Object test=null;
	Object test1=null;
	Cookie[]cookies=request.getCookies();
	for(int i=0;cookies!=null&&i<cookies.length;i++)
	{
		if("userbean".equals(cookies[i].getName())){
			test=cookies[i].getValue();
			break;
		}
	}
	for(int i=0;cookies!=null&&i<cookies.length;i++)
	{
		if("role".equals(cookies[i].getName())){
			test1=cookies[i].getValue();
			break;
		}
	}
	if(test==null||test1.equals("users")){
%>
	<jsp:forward page="loginin.jsp"></jsp:forward>
<% return;}%>
<% 
	Connection conn=null;
	Statement stmt=null;
	ResultSet rs=null;
	String table=null;
	//	获取数据连接
		conn=JDBCUtils.getConnection();
	//	获取Statement对象
		stmt=conn.createStatement();
	//	发送SQL语句
		String sql="select * from users";
		rs=stmt.executeQuery(sql);
		//删除数据
		
%>
	<div align="center">
        <table>
			<tr>
				<th>用户名</th>
				<th>密码</th>
				<th>角色</th>
				<th>数据存放位置</th>
				<th>操作</th>
			</tr>
			<% 
				while(rs.next()){
					String name=rs.getString("name");
					String password=rs.getString("password");
					String tables=rs.getString("tables");
			%>
			<tr>
 				<td> <%out.print(name);%> </td>
 				<td> <%out.print(password);%> </td>
 				<td>普通用户</td>
 				<td><%out.print(tables);%></td>
 				<td style="width:10%">
	 				<form action="DeleteUser" method="POST">
	                    <input type="submit" value="删除" >
	                    <input type="hidden" name="name" value=<%out.print(name);%>>
	                    <input type="hidden" name="table" value=<%out.print(tables);%>>
	                </form>
 				</td>
			</tr>
			
			<% } %>
			
		</table>
		 <div style="color:green;width:100%;text-align:center;">${DBMes}</div>
      </div>
</body>
</html>